﻿function StringBuilder(value)
{
	this.strings = new Array("");
	this.append(value);
}
StringBuilder.prototype.append = function (value)
{
	if (value)
	{
		this.strings.push(value);
	}
}
StringBuilder.prototype.clear = function ()
{
	this.strings.length = 1;
}
StringBuilder.prototype.toString = function ()
{
	return this.strings.join("");
}
if (!String._FORMAT_SEPARATOR){
String._FORMAT_SEPARATOR = String.fromCharCode(0x1f);
String._FORMAT_ARGS_PATTERN = new RegExp('^[^' + String._FORMAT_SEPARATOR + ']*'
    + new Array(100).join('(?:.([^' + String._FORMAT_SEPARATOR + ']*))?'));
}
if (!String.format)
{
String.format = function (s){
	return Array.prototype.join.call(arguments, String._FORMAT_SEPARATOR).
		replace(String._FORMAT_ARGS_PATTERN, s);
}
}
if (!''.format)
{
String.prototype.format = function (){
return (String._FORMAT_SEPARATOR +
    Array.prototype.join.call(arguments, String._FORMAT_SEPARATOR)).
    replace(String._FORMAT_ARGS_PATTERN, this);
}
}

//热门搜索
//type=0 热门搜索 1推荐小说
function GetTop(type)
{
    var sb=new StringBuilder();
    var title="热门搜索";
    var arr_data=HotSearch;
    if(type==1)
    {
      arr_data=HotRecom;
      title="推荐小说";
    }
    sb.append("<div class=\"box box_height_2\">");
    sb.append("<div class=\"box_tt\"><h2>$1</h2></div>".format(title));
    sb.append("<div class=\"box_con\"><div class=\"list_col2\"><ol class=\"ranklist ranklist_txt\">");
    
    for(var index=0;index<arr_data.length;index++)
    {
        if(index<=2)
        {
            sb.append("<li class=\"top\">");
        }
        else
        {
            sb.append("<li>");
        }
        sb.append("<em>$1</em><a target=\"_blank\" href=\"/Book.aspx?bookId=$2&siteId=$3\" title=\"由$4网$5更新\">$6</a></li>".format(index+1,
        arr_data[index][0],arr_data[index][2],arr_data[index][3],arr_data[index][4],arr_data[index][1]));
    }
    sb.append("</ol></div></div></div>");
    return sb.toString();
}

//最新更新
function GetLastUpdate()
{
    var sb=new StringBuilder();
    sb.append("<div class=\"box box_a box_fullcol box_coop\" style=\"width: 750px; height: 695px;\">");
    sb.append("<div class=\"box_con\">");
    sb.append("<h2>最近更新</h2><div class=\"colmain\">");
    for(var index=0;index<LastUpdate.length;index++)
    {
    sb.append("<ul><li class=\"ro0\">[<a href=\"/BookList.aspx?k=$1\" target=\"_blank\">$2</a>]</li><li class=\"ro1\"><a href=\"/Book.aspx?bookId=$3&siteId=$4\" class=\"f14\" target=\"_blank\">$5</a></li><li class=\"ro2\"><a href=\"/reader.aspx?chapterId=$6&siteId=$4\" target=\"_blank\">$7</a></li><li class=\"ro3\"><a href=\"bookList.aspx?k=$10&t=2\" target=\"_blank\">$8</a></li><li class=\"ro4\">$9</li></ul>".format(escape( LastUpdate[index][0]),
    LastUpdate[index][0],LastUpdate[index][1],LastUpdate[index][4],LastUpdate[index][2],LastUpdate[index][6],LastUpdate[index][7],LastUpdate[index][3],LastUpdate[index][5],escape(LastUpdate[index][3])));
    if(index==20)
    break;
    }
    sb.append("</div></div></div>");
    return sb.toString();
}